﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IBLL;
using IDAL;

namespace BLL
{
    public class MessagesInVideoDisplay : IMessagesInVideoDisplay
    {
        private static readonly IDAL.IMessage dal = DALFactory.DataAccess.CreateMessage();

        public MessagesInVideoDisplay()
        {
        }

        public IOrderedQueryable GetMessagesByVideoID(int videoID)
        {
            return dal.GetMessagesByVideoID(videoID);
        }

        public IOrderedQueryable GetMessagesByVideoIDOnePage(int videoID, int pageNum)
        {
            int startNum = 0;
            int takeNum = 10;
            if (pageNum > 0)
                startNum = (pageNum - 1) * 10;
            return dal.GetMessagesByVideoIDOnePage(videoID, startNum, takeNum);
        }

        public void InsertMessage(DataMode.message msg)
        {
            dal.InsertMessage(msg);
            return;
        }

        public int GetMessagesTotalPageNumByVideoID(int videoID)
        {
            return (dal.GetMessagesNumByVideoID(videoID) / 10 + 1);
        }


        public void DeleteMessageByMessageID(int messageID)
        {
            dal.DeleteMessageByMessageID(messageID);
            return;
        }

        public string GetUserNameOfMessage(int messageID)
        {
            return dal.GetUserNameOfMessage(messageID);
        }

        public int GetUserIDByUserName(string username)
        {
            return dal.GetUserIDByUserName(username);
        }

    }
}
